﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;

namespace SemestralniPraceY35VAN
{
    class Group
    {
        /// <summary>
        /// Properties of the group.
        /// </summary>
        private Hashtable properties;

        /// <summary>
        /// 
        /// </summary>
        public string Type { get { if (properties.ContainsKey("type")) return (string)properties["type"]; else return ""; } }

        /// <summary>
        /// 
        /// </summary>
        public List<Venue> Venues { get { if (properties.ContainsKey("venues")) return (List<Venue>)properties["venues"]; else return null; } }

        /// <summary>
        /// Constructs an object representing a mayor.
        /// </summary>
        /// <param name="mayor">XML node with information about the mayor</param>
        public Group(XmlNode group)
        {
            properties = new Hashtable();

            if (group.Name == "group")
            {
                if (group.Attributes["type"] != null)
                {
                    properties.Add("type", group.Attributes["type"].InnerText);
                }

                List<Venue> venues = new List<Venue>();

                for (int i = 0; i < group.ChildNodes.Count; i++)
                {
                    switch (group.ChildNodes[i].Name)
                    {
                        case "venue":
                            venues.Add(new Venue(group.ChildNodes[i]));
                            break;
                    }
                }

                properties.Add("venues", venues);
            }
            else
            {
                throw new IOException("Not Group!");
            }
        }
    }
}
